import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kq_flutter_tv_widgets/resources/kq_theme_colors.dart';
import 'package:kq_flutter_tv_widgets/widgets/button/kq_outline_button.dart';
import 'package:kq_flutter_tv_widgets/widgets/calendar/kq_calendar.dart';

class KqCalendarPage extends StatefulWidget {
  const KqCalendarPage({super.key});

  @override
  State<KqCalendarPage> createState() => _KqCalendarPageState();
}

class _KqCalendarPageState extends State<KqCalendarPage> {
  String? time;
  bool isShow = true;
  DateTime? startTime;
  DateTime? endTime;
  DateTime? focusedDay;

  DateTime rangeStart = DateTime.utc(2023, 10, 11);
  DateTime rangeEnd = DateTime.utc(2023, 10, 16);

  @override
  Widget build(BuildContext context) {
    double width = context.mediaQuery.size.width / 2;
    double heigh = context.mediaQuery.size.height;
    return Scaffold(
        body: Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          height: 54,
          padding: const EdgeInsets.all(10),
          child: KqOutlineButton(
            title: time ?? '',
            textColor: KqThemeColors.text333,
            onTap: (disabled) {
              setState(() {
                isShow = !isShow;
                rangeStart = DateTime.utc(2023, 10, 12);
                rangeEnd = DateTime.utc(2023, 10, 16);
              });
            },
          ),
        ),
        Container(
          color: Colors.red,
          width: width,
          child: KqCalendar(
            selectMode: KQSelectMode.range,
            focusedDay: DateTime.utc(2023, 11, 2),
            // selectedDay: DateTime.utc(2023, 11, 2),
            rangeStart: rangeStart,
            rangeEnd: rangeEnd,
            limitStartTime: DateTime.utc(2022, 10, 01),
            limitEndTime: DateTime.utc(2023, 11, 3),
          ),
        )
      ],
    ));
  }
}
